﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AndroidEditor.WForm;
using System.IO;

namespace AndroidEditor
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks></remarks>
    public partial class NprojectType : Form
    {
        /// <summary>
        /// 
        /// </summary>
        private object thisObject = null;
        /// <summary>
        /// 
        /// </summary>
        private ListViewItem sItem = null;
        /// <summary>
        /// 
        /// </summary>
        private string ProjectPath = "";
        /// <summary>
        /// Initializes a new instance of the <see cref="NprojectType"/> class.
        /// </summary>
        /// <remarks></remarks>
        public NprojectType()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Handles the Load event of the NprojectType control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        private void NprojectType_Load(object sender, EventArgs e)
        {
             
            // icon 1
             sItem = listView1.Items.Add("静态类库", 0);
            
            sItem.Tag = new SNClass();
            sItem.Selected = true;
            //icon  2
            listView1.Items.Add("动态类库", 0).Tag = new DNClass();
            //icon 3
            listView1.Items.Add("应用程序", 1).Tag = new NApp();
       


        }

        /// <summary>
        /// Handles the Click event of the button1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        private void button1_Click(object sender, EventArgs e)
        {
            if (CheckCondation())
            {
                DialogResult = DialogResult.OK;
            }
        }
        //检查确定条件
        /// <summary>
        /// Checks the condation.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        private bool CheckCondation()
        {
            if (listView1.SelectedItems.Count != 1)
            {
                sItem.Selected = true;
                return false;
            }
            if (textBox1.Text.Length == 0)
            {
                sItem.Selected = true;
                
                return false;
            }
             


            return true;
        }

        /// <summary>
        /// Handles the Click event of the button2 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        /// <summary>
        /// Handles the SelectedIndexChanged event of the listView1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (listView1.SelectedItems.Count > 0)
            {
                thisObject = listView1.SelectedItems[0].Tag;
                label2.Text = listView1.SelectedItems[0].Text;
            }
            else
            {
                label2.Text = "无选择"; 
            }
        }

        /// <summary>
        /// Gets the type of the select.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        public PType GetSelectType()
        {
            try
            {
                DNClass TYPEobject = (DNClass)thisObject;
                return PType.动态库;
            }
            catch (System.Exception ex)
            {

            }
            try
            {
                SNClass TYPEobject = (SNClass)thisObject;
                return PType.静态库;
            }
            catch (System.Exception ex)
            {

            }

            return PType.应用程序;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <remarks></remarks>
        public enum PType
        {
            /// <summary>
            /// 
            /// </summary>
            静态库 = 0, 动态库, 应用程序
        }

        public CType isCPlusPlus()
        {
            if (checkBox1.Checked)
            {
                return CType.CPlusPlus;
            }
            return CType.C;
        }
        public enum CType
        {
            C = 0, CPlusPlus
        }

        

        public string getProjectName()
        {
            return textBox1.Text;
        }



        public string GetProejctPath()
        {
            return ProjectPath;
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        
    }
}
